<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<meta http-equiv="Content-Type" content="text/html;" charset="<?php echo CHARSET;?>">
<title>本地生活</title>
<link href="/Public/admin/css/skin_0.css" rel="stylesheet" type="text/css" id="cssfile"/>
<script type="text/javascript" src="/Public/static/jquery.js"></script>
<script type="text/javascript" src="/Public/static/jquery.validation.min.js"></script>
<script type="text/javascript" src="/Public/admin/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Public/admin/js/admincp.js"></script>
<script type="text/javascript" src="/Public/admin/js/jquery.tooltip.js"></script>
<script language="javascript">
var SiteUrl = '<?php echo (C("SiteUrl")); ?>';
var AdminUrl = SiteUrl+'/<?php echo (MODULE_NAME); ?>';
</script>
</head><body>
<div class="page">
  <div class="fixed-bar">
    <div class="item-title">
      <h3>广告管理</h3>
      <ul class="tab-base">
        <li><a href="<?php echo U('Billboards/position');?>"><span>管理</span></a></li>
        <li><a href="JavaScript:void(0);" class="current"><span>新增</span></a></li>
      </ul>
    </div>
  </div>
  <div class="fixed-empty"></div>
  <form id="link_form" enctype="multipart/form-data" method="post" action="<?php echo U('Billboards/add');?>">
    <table class="table tb-type2">
      <tbody>
        <tr class="noborder">
          <td colspan="2" class="required"><label class="validation" for="ap_name">名称:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" name="ap_name" id="ap_name" class="txt">
            </td>
          <td class="vatop tips"></td>
        </tr>
        <tr class="noborder">
          <td colspan="2" class="required"><label class="validation" for="ap_code">广告位置:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform">
          <select name="ap_code" id="ap_code">
          <option value="">请选择...</option>
          <?php if(is_array($apcode)): $i = 0; $__LIST__ = $apcode;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><option value="<?php echo ($vo['ap_code']); ?>"><?php echo ($vo['name']); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
          </select>
          </td>
          <td class="vatop tips"></td>
        </tr>        
        <tr class="noborder">
          <td colspan="2" class="required"><label for="ap_link">链接地址:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" name="ap_link" id="ap_link" class="txt">
            </td>
          <td class="vatop tips">以http://开头</td>
        </tr>
      </tbody>
      
      <tbody>
        <tr>
          <td colspan="2" class="required"><label class="validation" for="change_default_pic">图片</label></td>
        </tr>
          <td class="vatop rowform">
          	<span class="type-file-show">
          		<!--<img class="show_image" src="/Public/admin/images/preview.png">-->
            	<div class="type-file-preview">
            		<img src="/Uploads/<?php echo ($vo['ap_pic']); ?>">
            	</div>
            </span>
            <span class="type-file-box">
            <input type='text' name='txt_default_pic' id='txt_default_pic' class='type-file-text' />
            <input type='button' name='but_default_pic' id='but_default_pic' value='' class='type-file-button' />
            <input name="default_pic" type="file" class="type-file-file" id="default_pic" size="30" hidefocus="true" nc_type="change_default_pic">
            </span>
          </td>
          <td class="vatop tips"></td>
      </tbody>
      <tbody id="ap_sort_media">
        <tr>
          <td colspan="2" class="required"><label class="validation" for="ap_sort_media_input">排序:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" value="" name="ap_sort"  class="txt" id="ap_sort_media_input"></td>
          <td class="vatop tips"></td>
        </tr>
	  </tbody>
    <tbody id="default_word">
    <tr>
      <td colspan="2" class="required"><label>简介:</label></td>
    </tr>
    <tr class="noborder">
      <td class="vatop rowform">
      <textarea name="ap_intro" rows="6" class="tarea" id="ap_intro"></textarea>
      </td>
      <td class="vatop tips"></td>
    </tr>
  </tbody>      
      
      <tfoot>
        <tr class="tfoot">
          <td colspan="15" ><a href="JavaScript:void(0);" class="btn" id="submitBtn"><span>保存</span></a></td>
        </tr>
      </tfoot>
    </table>
  </form>
</div>
<script type="text/javascript">
/*$(function(){
	$("#default_word").hide();
	$("#ap_class").change(function(){
	if($("#ap_class").val() == '1'){
		$("#ap_height").hide();
		$("#ap_width_media").hide();
		$("#default_pic").hide();
		$("#default_word").show();
	}else if($("#ap_class").val() == '2'){
		$("#ap_height").show();
		$("#ap_width_media").show();
		$("#default_pic").show();
		$("#default_word").hide();
	}else{
		$("#ap_height").show();
		$("#ap_width_media").show();
		$("#default_pic").show();
		$("#default_word").hide();
	}
  });
});*/
</script> 
<script>
//按钮先执行验证再提交表单
$(function(){$("#submitBtn").click(function(){
    if($("#link_form").valid()){
     $("#link_form").submit();
	}
	});
});
//
$(document).ready(function(){
	$('#link_form').validate({
        errorPlacement: function(error, element){
			error.appendTo(element.parent().parent().prev().find('td:first'));
        },
        success: function(label){
            label.addClass('valid');
        },
        rules : {
        	ap_name : {
                required : true
            },
			ap_code : {
				 required : true	
			},
            ap_link:{
				url : true
           	}	
/*			ap_width:{
				required :function(){return $("#ap_class").val()!=1;},
				digits	 :true,
				min:1
			},
			ap_height:{
				required :function(){return $("#ap_class").val()!=1;},
				digits	 :true,
				min:1
			},
			default_content  :{
				required :function(){return $("#ap_class").val()==1;}
			}*/
        },
        messages : {
        	ap_name : {
                required : '请输入标题'
            },
			ap_code : {
				 required : '请输入调用代码'	
			},			
            ap_link : {
				url : '链接地址格式错误'
            }		
/*            ap_width	:{
            	required : '请输入宽度',
            	digits	:'格式错误',
            	min	:'1px以上'
            },
            ap_height	:{
            	required   : '请输入高度',
            	digits	:'格式错误',
            	min	:'1px以上'
            },            
            default_content	:{
            	required   : '请输入文字信息'
            }*/
        }
    });
});
</script>
<script type="text/javascript">
// 模拟网站LOGO上传input type='file'样式
$(function(){
	$("#default_pic").change(function(){
		$("#txt_default_pic").val($(this).val());
	});
// 上传图片类型
$('input[class="type-file-file"]').change(function(){
	var filepatd=$(this).val();	
	var extStart=filepatd.lastIndexOf(".");
	var ext=filepatd.substring(extStart,filepatd.lengtd).toUpperCase();		
		if(ext!=".PNG"&&ext!=".GIF"&&ext!=".JPG"&&ext!=".JPEG"){
			alert("图片格式错误");
				$(this).attr('value','');
			return false;
		}
	});
});
</script>
</body></html>